<!DOCTYPE html><html><head>
      <title>README</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      
      <link rel="stylesheet" href="file:///c:\Users\wulin\.vscode\extensions\shd101wyy.markdown-preview-enhanced-0.8.10\crossnote\dependencies\katex\katex.min.css">
      
      
      
      
      
      <style>
      code[class*=language-],pre[class*=language-]{color:#333;background:0 0;font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.4;-moz-tab-size:8;-o-tab-size:8;tab-size:8;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*=language-]{padding:.8em;overflow:auto;border-radius:3px;background:#f5f5f5}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal;background:#f5f5f5}.token.blockquote,.token.comment{color:#969896}.token.cdata{color:#183691}.token.doctype,.token.macro.property,.token.punctuation,.token.variable{color:#333}.token.builtin,.token.important,.token.keyword,.token.operator,.token.rule{color:#a71d5d}.token.attr-value,.token.regex,.token.string,.token.url{color:#183691}.token.atrule,.token.boolean,.token.code,.token.command,.token.constant,.token.entity,.token.number,.token.property,.token.symbol{color:#0086b3}.token.prolog,.token.selector,.token.tag{color:#63a35c}.token.attr-name,.token.class,.token.class-name,.token.function,.token.id,.token.namespace,.token.pseudo-class,.token.pseudo-element,.token.url-reference .token.variable{color:#795da3}.token.entity{cursor:help}.token.title,.token.title .token.punctuation{font-weight:700;color:#1d3e81}.token.list{color:#ed6a43}.token.inserted{background-color:#eaffea;color:#55a532}.token.deleted{background-color:#ffecec;color:#bd2c00}.token.bold{font-weight:700}.token.italic{font-style:italic}.language-json .token.property{color:#183691}.language-markup .token.tag .token.punctuation{color:#333}.language-css .token.function,code.language-css{color:#0086b3}.language-yaml .token.atrule{color:#63a35c}code.language-yaml{color:#183691}.language-ruby .token.function{color:#333}.language-markdown .token.url{color:#795da3}.language-makefile .token.symbol{color:#795da3}.language-makefile .token.variable{color:#183691}.language-makefile .token.builtin{color:#0086b3}.language-bash .token.keyword{color:#0086b3}pre[data-line]{position:relative;padding:1em 0 1em 3em}pre[data-line] .line-highlight-wrapper{position:absolute;top:0;left:0;background-color:transparent;display:block;width:100%}pre[data-line] .line-highlight{position:absolute;left:0;right:0;padding:inherit 0;margin-top:1em;background:hsla(24,20%,50%,.08);background:linear-gradient(to right,hsla(24,20%,50%,.1) 70%,hsla(24,20%,50%,0));pointer-events:none;line-height:inherit;white-space:pre}pre[data-line] .line-highlight:before,pre[data-line] .line-highlight[data-end]:after{content:attr(data-start);position:absolute;top:.4em;left:.6em;min-width:1em;padding:0 .5em;background-color:hsla(24,20%,50%,.4);color:#f4f1ef;font:bold 65%/1.5 sans-serif;text-align:center;vertical-align:.3em;border-radius:999px;text-shadow:none;box-shadow:0 1px #fff}pre[data-line] .line-highlight[data-end]:after{content:attr(data-end);top:auto;bottom:.4em}html body{font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif;font-size:16px;line-height:1.6;color:#333;background-color:#fff;overflow:initial;box-sizing:border-box;word-wrap:break-word}html body>:first-child{margin-top:0}html body h1,html body h2,html body h3,html body h4,html body h5,html body h6{line-height:1.2;margin-top:1em;margin-bottom:16px;color:#000}html body h1{font-size:2.25em;font-weight:300;padding-bottom:.3em}html body h2{font-size:1.75em;font-weight:400;padding-bottom:.3em}html body h3{font-size:1.5em;font-weight:500}html body h4{font-size:1.25em;font-weight:600}html body h5{font-size:1.1em;font-weight:600}html body h6{font-size:1em;font-weight:600}html body h1,html body h2,html body h3,html body h4,html body h5{font-weight:600}html body h5{font-size:1em}html body h6{color:#5c5c5c}html body strong{color:#000}html body del{color:#5c5c5c}html body a:not([href]){color:inherit;text-decoration:none}html body a{color:#08c;text-decoration:none}html body a:hover{color:#00a3f5;text-decoration:none}html body img{max-width:100%}html body>p{margin-top:0;margin-bottom:16px;word-wrap:break-word}html body>ol,html body>ul{margin-bottom:16px}html body ol,html body ul{padding-left:2em}html body ol.no-list,html body ul.no-list{padding:0;list-style-type:none}html body ol ol,html body ol ul,html body ul ol,html body ul ul{margin-top:0;margin-bottom:0}html body li{margin-bottom:0}html body li.task-list-item{list-style:none}html body li>p{margin-top:0;margin-bottom:0}html body .task-list-item-checkbox{margin:0 .2em .25em -1.8em;vertical-align:middle}html body .task-list-item-checkbox:hover{cursor:pointer}html body blockquote{margin:16px 0;font-size:inherit;padding:0 15px;color:#5c5c5c;background-color:#f0f0f0;border-left:4px solid #d6d6d6}html body blockquote>:first-child{margin-top:0}html body blockquote>:last-child{margin-bottom:0}html body hr{height:4px;margin:32px 0;background-color:#d6d6d6;border:0 none}html body table{margin:10px 0 15px 0;border-collapse:collapse;border-spacing:0;display:block;width:100%;overflow:auto;word-break:normal;word-break:keep-all}html body table th{font-weight:700;color:#000}html body table td,html body table th{border:1px solid #d6d6d6;padding:6px 13px}html body dl{padding:0}html body dl dt{padding:0;margin-top:16px;font-size:1em;font-style:italic;font-weight:700}html body dl dd{padding:0 16px;margin-bottom:16px}html body code{font-family:Menlo,Monaco,Consolas,'Courier New',monospace;font-size:.85em;color:#000;background-color:#f0f0f0;border-radius:3px;padding:.2em 0}html body code::after,html body code::before{letter-spacing:-.2em;content:'\00a0'}html body pre>code{padding:0;margin:0;word-break:normal;white-space:pre;background:0 0;border:0}html body .highlight{margin-bottom:16px}html body .highlight pre,html body pre{padding:1em;overflow:auto;line-height:1.45;border:#d6d6d6;border-radius:3px}html body .highlight pre{margin-bottom:0;word-break:normal}html body pre code,html body pre tt{display:inline;max-width:initial;padding:0;margin:0;overflow:initial;line-height:inherit;word-wrap:normal;background-color:transparent;border:0}html body pre code:after,html body pre code:before,html body pre tt:after,html body pre tt:before{content:normal}html body blockquote,html body dl,html body ol,html body p,html body pre,html body ul{margin-top:0;margin-bottom:16px}html body kbd{color:#000;border:1px solid #d6d6d6;border-bottom:2px solid #c7c7c7;padding:2px 4px;background-color:#f0f0f0;border-radius:3px}@media print{html body{background-color:#fff}html body h1,html body h2,html body h3,html body h4,html body h5,html body h6{color:#000;page-break-after:avoid}html body blockquote{color:#5c5c5c}html body pre{page-break-inside:avoid}html body table{display:table}html body img{display:block;max-width:100%;max-height:100%}html body code,html body pre{word-wrap:break-word;white-space:pre}}.markdown-preview{width:100%;height:100%;box-sizing:border-box}.markdown-preview ul{list-style:disc}.markdown-preview ul ul{list-style:circle}.markdown-preview ul ul ul{list-style:square}.markdown-preview ol{list-style:decimal}.markdown-preview ol ol,.markdown-preview ul ol{list-style-type:lower-roman}.markdown-preview ol ol ol,.markdown-preview ol ul ol,.markdown-preview ul ol ol,.markdown-preview ul ul ol{list-style-type:lower-alpha}.markdown-preview .newpage,.markdown-preview .pagebreak{page-break-before:always}.markdown-preview pre.line-numbers{position:relative;padding-left:3.8em;counter-reset:linenumber}.markdown-preview pre.line-numbers>code{position:relative}.markdown-preview pre.line-numbers .line-numbers-rows{position:absolute;pointer-events:none;top:1em;font-size:100%;left:0;width:3em;letter-spacing:-1px;border-right:1px solid #999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.markdown-preview pre.line-numbers .line-numbers-rows>span{pointer-events:none;display:block;counter-increment:linenumber}.markdown-preview pre.line-numbers .line-numbers-rows>span:before{content:counter(linenumber);color:#999;display:block;padding-right:.8em;text-align:right}.markdown-preview .mathjax-exps .MathJax_Display{text-align:center!important}.markdown-preview:not([data-for=preview]) .code-chunk .code-chunk-btn-group{display:none}.markdown-preview:not([data-for=preview]) .code-chunk .status{display:none}.markdown-preview:not([data-for=preview]) .code-chunk .output-div{margin-bottom:16px}.markdown-preview .md-toc{padding:0}.markdown-preview .md-toc .md-toc-link-wrapper .md-toc-link{display:inline;padding:.25rem 0}.markdown-preview .md-toc .md-toc-link-wrapper .md-toc-link div,.markdown-preview .md-toc .md-toc-link-wrapper .md-toc-link p{display:inline}.markdown-preview .md-toc .md-toc-link-wrapper.highlighted .md-toc-link{font-weight:800}.scrollbar-style::-webkit-scrollbar{width:8px}.scrollbar-style::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}.scrollbar-style::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,.66);border:4px solid rgba(150,150,150,.66);background-clip:content-box}html body[for=html-export]:not([data-presentation-mode]){position:relative;width:100%;height:100%;top:0;left:0;margin:0;padding:0;overflow:auto}html body[for=html-export]:not([data-presentation-mode]) .markdown-preview{position:relative;top:0;min-height:100vh}@media screen and (min-width:914px){html body[for=html-export]:not([data-presentation-mode]) .markdown-preview{padding:2em calc(50% - 457px + 2em)}}@media screen and (max-width:914px){html body[for=html-export]:not([data-presentation-mode]) .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for=html-export]:not([data-presentation-mode]) .markdown-preview{font-size:14px!important;padding:1em}}@media print{html body[for=html-export]:not([data-presentation-mode]) #sidebar-toc-btn{display:none}}html body[for=html-export]:not([data-presentation-mode]) #sidebar-toc-btn{position:fixed;bottom:8px;left:8px;font-size:28px;cursor:pointer;color:inherit;z-index:99;width:32px;text-align:center;opacity:.4}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] #sidebar-toc-btn{opacity:1}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc{position:fixed;top:0;left:0;width:300px;height:100%;padding:32px 0 48px 0;font-size:14px;box-shadow:0 0 4px rgba(150,150,150,.33);box-sizing:border-box;overflow:auto;background-color:inherit}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar{width:8px}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,.66);border:4px solid rgba(150,150,150,.66);background-clip:content-box}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc a{text-decoration:none}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc .md-toc{padding:0 16px}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc .md-toc .md-toc-link-wrapper .md-toc-link{display:inline;padding:.25rem 0}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc .md-toc .md-toc-link-wrapper .md-toc-link div,html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc .md-toc .md-toc-link-wrapper .md-toc-link p{display:inline}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc .md-toc .md-toc-link-wrapper.highlighted .md-toc-link{font-weight:800}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{left:300px;width:calc(100% - 300px);padding:2em calc(50% - 457px - 300px / 2);margin:0;box-sizing:border-box}@media screen and (max-width:1274px){html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{width:100%}}html body[for=html-export]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .markdown-preview{left:50%;transform:translateX(-50%)}html body[for=html-export]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .md-sidebar-toc{display:none}
/* Please visit the URL below for more information: */
/*   https://shd101wyy.github.io/markdown-preview-enhanced/#/customize-css */

      </style>
      <!-- The content below will be included at the end of the <head> element. --><script type="text/javascript">
  document.addEventListener("DOMContentLoaded", function () {
    // your code here
  });
</script></head><body for="html-export">
    
    
      <div class="crossnote markdown-preview  ">
      
<h2 id="1-简介">1. 简介 </h2>
<p>这是一个基于python的tkinter桌面端项目，主要使用人脸识别来实现一个简单的考勤系统。主要采用的技术如下：</p>
<ol>
<li>tkinter<br>
tkinter介绍：<br>
tkinter是一个跨平台的Python GUI工具包，它提供了一系列的GUI工具，可以用来构建图形用户界面。<br>
tkinter的特点：</li>
</ol>
<ul>
<li>跨平台：支持Windows、Mac OS X、Linux等操作系统。</li>
<li>简单易用：使用tkinter可以快速的构建出一个GUI程序。</li>
<li>功能富：tkinter提供了大量的GUI组件，可以满足大部分</li>
</ul>
<ol start="2">
<li>MySQL<br>
MySQL介绍：<br>
MySQL是一个关系型数据库管理系统，由瑞典MySQL AB 公司开发，目前属于 Oracle 旗下产品。MySQL 是最流行的关系型数据库管理系统之一，在 WEB 应用方面，MySQL 是最好的 RDBMS (Relational Database Management System，关系数据库管理系统)，它支持多种数据库引擎，包括但不限于：MySQL、Oracle、Microsoft SQL Server、IBM DB2、Informix、Sybase、Firebird 等，并且支持各种开发语言，包括 Python、Ruby、PHP、C/C++、C#、Go等<br>
pymysql介绍：<br>
pymysql是一个纯Python编写的MySQL数据库客户端，支持Python2.x和Python3.x。<br>
pymysql的特点：</li>
</ol>
<ul>
<li>纯Python编写，不依赖任何C扩展，支持Python2.x和Python3.x。</li>
<li>纯Python，无需编译，安装简单。</li>
</ul>
<h3 id="11-项目目标">1.1 项目目标 </h3>
<p>编写一个简单易用的基于人脸识别的学生考勤系统。</p>
<h3 id="12-项目结构">1.2 项目结构 </h3>
<pre data-role="codeBlock" data-info="" class="language-text text"><code>.
├── config
│   └── config.toml
├── dao
│   ├── Results.py
├── models
│   ├── models.py
├── Login.py
├── pages.py
├── README.MD
└── test.py
</code></pre><p>其中config.toml是配置文件，用于配置数据库连接信息。<br>
dao是数据访问层，主要用于操作数据库。<br>
models是数据模型层，主要用于定义数据库表结构。<br>
pages是页面，主要用于定义页面的布局和功能。<br>
test是测试文件，用于测试程序。<br>
如需测试某个功能，可以直接在test.py中进行测试。<br>
以上便是本项目简单的项目结构</p>
<h3 id="13-项目依赖">1.3 项目依赖 </h3>
<pre data-role="codeBlock" data-info="" class="language-text text"><code>pip install tkinter
#一般python自带tkinter，请用pip list查看是否拥有tkinter，若没有使用上述命令安装
pip install pymysql
#使用上述命令安装pymysql,与数据库进行交互
</code></pre><p>以上安装如果网络不好会很慢，此处建议使用镜像安装，镜像可以选择清华源，或者豆瓣源，或者阿里源，或者腾讯源。<br>
清华源：</p>
<pre data-role="codeBlock" data-info="" class="language-text text"><code>pip install NAME -i https://pypi.tuna.tsinghua.edu.cn/simple/
</code></pre><p>豆瓣源：</p>
<pre data-role="codeBlock" data-info="" class="language-text text"><code>pip install NAME -i https://pypi.doubanio.com/simple/
</code></pre><p>阿里源：</p>
<pre data-role="codeBlock" data-info="" class="language-text text"><code>pip install NAME -i https://mirrors.aliyun.com/pypi/simple/
</code></pre><p>腾讯源：</p>
<pre data-role="codeBlock" data-info="" class="language-text text"><code>pip install NAME -i https://mirrors.cloud.tencent.com/pypi/simple/
</code></pre><h3 id="14-项目运行">1.4 项目运行 </h3>
<p>首先需要安装依赖，然后在config.toml文件中配置数据库连接信息，最后运行Login.py文件即可。</p>
<h3 id="15-项目测试">1.5 项目测试 </h3>
<h4 id="单元测试">单元测试 </h4>
<p>什么是单元测试?<br>
单元测试是一种软件测试方法，它是一种针对程序模块（或函数）的测试，是对软件进行正确性检验的一种形式，是一种能够发现程序中的错误的测试方法。</p>
<ol>
<li>单元测试的好处<br>
单元测试的好处是可以快速的发现错误，并且可以保证程序的正确性。</li>
<li>单元测试的坏处<br>
单元测试的坏处是需要编写大量的测试代码，并且测试代码的维护成本较高。</li>
</ol>
<p>如何用python进行单元测试</p>
<ol>
<li>导入unittest模块</li>
</ol>
<pre data-role="codeBlock" data-info="python" class="language-python python"><code><span class="token keyword keyword-import">import</span> unittest
</code></pre><ol start="2">
<li>继承unittest.TestCase类</li>
</ol>
<pre data-role="codeBlock" data-info="python" class="language-python python"><code><span class="token keyword keyword-class">class</span> <span class="token class-name">TestLogin</span><span class="token punctuation">(</span>unittest<span class="token punctuation">.</span>TestCase<span class="token punctuation">)</span><span class="token punctuation">:</span>
    <span class="token keyword keyword-def">def</span> <span class="token function">test_login</span><span class="token punctuation">(</span>self<span class="token punctuation">)</span><span class="token punctuation">:</span>
        self<span class="token punctuation">.</span>assertEqual<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">)</span>
</code></pre><ol start="3">
<li>运行测试</li>
</ol>
<pre data-role="codeBlock" data-info="python" class="language-python python"><code><span class="token keyword keyword-if">if</span> __name__ <span class="token operator">==</span> <span class="token string">'__main__'</span><span class="token punctuation">:</span>
</code></pre><p>2023年11月23日:<br>
测试各页面UI<br>
测试结果：<br>
登录注册<br>
<img src="https://free.wzznft.com/i/2023/11/23/j5h3g3.png" alt=""><br>
主页<br>
<img src="https://s1.wzznft.com/i/2023/11/23/j67p8v.png" alt=""><br>
历史记录<br>
<img src="https://free.wzznft.com/i/2023/11/23/jv302i.png" alt=""><br>
请假记录<br>
<img src="https://free.wzznft.com/i/2023/11/23/jvvh3d.png" alt=""><br>
关于我们<br>
<img src="https://s1.wzznft.com/i/2023/11/23/jwef66.png" alt=""><br>
个人界面<br>
<img src="https://free.wzznft.com/i/2023/11/23/jwjtcu.png" alt=""></p>
<p>2023年11月23日:<br>
测试数据库连接<br>
单元测试<br>
<img src="https://free.wzznft.com/i/2023/11/23/qgskj3.png" alt=""><br>
<img src="https://free.wzznft.com/i/2023/11/23/psad8f.png" alt=""><br>
测试结果：<br>
<img src="https://free.wzznft.com/i/2023/11/23/psfiuy.png" alt=""></p>
<p>2023年11月24日:<br>
测试配置文件<br>
单元测试<br>
<img src="https://free.wzznft.com/i/2023/11/24/srydm4.png" alt=""><br>
<img src="https://free.wzznft.com/i/2023/11/24/ss34tb.png" alt=""><br>
测试结果：<br>
<img src="https://free.wzznft.com/i/2023/11/24/st6zjo.png" alt=""></p>
<p>2023年11月25日:<br>
测试历史表格页面<br>
页面测试<br>
由于滚动不能选择滚动部分区域，所以超过三个的数据显示在单独页面中<br>
<img src="https://free.wzznft.com/i/2023/11/27/sefd4u.png" alt=""></p>
<p>2023年11月26日:<br>
测试高级页面<br>
页面测试<br>
切换数据库链接<br>
<img src="https://free.wzznft.com/i/2023/11/26/s9447f.png" alt=""></p>
<p>2023年11月27日:<br>
测试数据库与配置文件链接<br>
单元测试<br>
<img src="https://s1.wzznft.com/i/2023/11/27/piya1x.png" alt=""><br>
<img src="https://s1.wzznft.com/i/2023/11/27/pialay.png" alt=""></p>
<h3 id="16-项目部署">1.6 项目部署 </h3>
<p>已封装为类，可以直接使用。</p>
<pre data-role="codeBlock" data-info="python" class="language-python python"><code><span class="token keyword keyword-from">from</span> Login <span class="token keyword keyword-import">import</span> Login
login <span class="token operator">=</span> Login<span class="token punctuation">(</span><span class="token punctuation">)</span>
login<span class="token punctuation">.</span>start<span class="token punctuation">(</span><span class="token punctuation">)</span>
</code></pre><h3 id="17-项目文档">1.7 项目文档 </h3>
<h2 id="附录">附录 </h2>
<h3 id="什么是toml文件">什么是toml文件？ </h3>
<h4 id="1-什么是toml文件">1. 什么是toml文件？ </h4>
<p>TOML 是一种易于人阅读和编写的格式，用于存储数据。它是由 TOML 创始人 Donald Knuth 创造的，并在 2010 年 6 月 23 日发布。</p>
<h4 id="2python如何使用toml文件">2.python如何使用toml文件？ </h4>
<p>Python 内置了对 TOML 文件的支持，使用模块 <code>toml</code> 即可。</p>
<p>config.toml文件</p>
<pre data-role="codeBlock" data-info="toml" class="language-toml toml"><code><span class="token punctuation">[</span><span class="token table class-name">database</span><span class="token punctuation">]</span>
<span class="token key property">host</span> <span class="token punctuation">=</span> <span class="token string">"localhost"</span>
<span class="token key property">port</span> <span class="token punctuation">=</span> <span class="token number">3306</span>
<span class="token key property">user</span> <span class="token punctuation">=</span> <span class="token string">"root"</span>
<span class="token key property">password</span> <span class="token punctuation">=</span> <span class="token string">"123456"</span>
</code></pre><p>完整的例子</p>
<pre data-role="codeBlock" data-info="python" class="language-python python"><code><span class="token keyword keyword-import">import</span> toml
<span class="token keyword keyword-import">import</span> os
<span class="token comment"># 读取文件</span>
<span class="token keyword keyword-with">with</span> <span class="token builtin">open</span><span class="token punctuation">(</span><span class="token string">"config.toml"</span><span class="token punctuation">,</span> <span class="token string">"r"</span><span class="token punctuation">)</span> <span class="token keyword keyword-as">as</span> f<span class="token punctuation">:</span>
    config <span class="token operator">=</span> toml<span class="token punctuation">.</span>load<span class="token punctuation">(</span>f<span class="token punctuation">)</span>

<span class="token comment"># 获取配置信息</span>
<span class="token keyword keyword-print">print</span><span class="token punctuation">(</span>config<span class="token punctuation">[</span><span class="token string">"database"</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token string">"host"</span><span class="token punctuation">]</span><span class="token punctuation">)</span>
<span class="token keyword keyword-print">print</span><span class="token punctuation">(</span>config<span class="token punctuation">[</span><span class="token string">"database"</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token string">"user"</span><span class="token punctuation">]</span><span class="token punctuation">)</span>
<span class="token keyword keyword-print">print</span><span class="token punctuation">(</span>config<span class="token punctuation">[</span><span class="token string">"database"</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token string">"password"</span><span class="token punctuation">]</span><span class="token punctuation">)</span>

<span class="token comment"># 读取环境变量</span>
host <span class="token operator">=</span> os<span class="token punctuation">.</span>getenv<span class="token punctuation">(</span><span class="token string">"HOST"</span><span class="token punctuation">)</span>
user <span class="token operator">=</span> os<span class="token punctuation">.</span>getenv<span class="token punctuation">(</span><span class="token string">"USER"</span><span class="token punctuation">)</span>
</code></pre><h3 id="markdown工具推荐">markdown工具推荐 </h3>
<p>什么是markdown？<br>
Markdown 是一种轻量级标记语言，用简洁的语法代替排版，可以使文档更易读、易写。</p>
<h4 id="typora">Typora </h4>
<p>Typora 是一款支持 Markdown 格式的跨平台的 Markdown 编辑器，支持 Windows、Mac、Linux 等操作系统。</p>
<h5 id="1-typora安装">1. Typora安装 </h5>
<p>下载Typora安装包，解压，双击运行即可。</p>
<h5 id="2-typora使用">2. Typora使用 </h5>
<p>打开Typora，点击菜单栏的<code>文件</code> -&gt; <code>打开</code>，选择要打开的Markdown文件</p>
<h4 id="vscode的markdown插件">vscode的markdown插件 </h4>
<h5 id="1-安装markdown插件">1. 安装markdown插件 </h5>
<p>打开vscode，点击插件栏的<code>插件</code> -&gt; <code>市场</code> -&gt; <code>搜索markdown</code> -&gt; <code>Markdown Preview Enhanced</code> -&gt; <code>安装</code></p>
<h5 id="2-使用markdown插件">2. 使用markdown插件 </h5>
<p>打开vscode，点击md文件，右键侧边预览即可</p>
<h3 id="4-项目部署截图">4. 项目部署截图 </h3>
<p><img src="https://s1.wzznft.com/i/2023/11/20/ntov8z.png" alt="image"></p>
<h3 id="编辑器ide启动详解">编辑器（IDE）启动详解 </h3>
<h4 id="1-编辑器ide说明">1. 编辑器（IDE）说明 </h4>
<p>1.代码编辑器（Code Editor）是一种软件，它允许用户通过键盘和鼠标来编辑源代码。<br>
2.集成开发环境（Integrated Development Environment，简称 IDE）是一种软件，它包括了软件开发的环境，包括编译器、调试器、代码编辑器、项目管理工具、图形用户界面等。</p>
<h4 id="2-编辑器ide安装">2. 编辑器（IDE）安装 </h4>
<p>1.安装pycharm<br>
pycharm是 JetBrains 公司开发的一款Python IDE，它集成了代码编辑器、调试器、版本管理工具、项目管理工具、图形用户界面等。</p>
<h5 id="直接安装需付费">直接安装（需付费） </h5>
<pre data-role="codeBlock" data-info="bash" class="language-bash bash"><code><span class="token comment"># 下载地址</span>
https://www.jetbrains.com/pycharm/download/<span class="token comment">#section=windows</span>
</code></pre><pre data-role="codeBlock" data-info="bash" class="language-bash bash"><code><span class="token comment"># 安装步骤</span>
<span class="token comment"># 1.下载安装包</span>
<span class="token comment"># 2.解压安装包</span>
<span class="token comment"># 3.运行pycharm.exe</span>
</code></pre><h5 id="破解安装无需付费">破解安装（无需付费） </h5>
<p>联系作者即可</p>
<p>2.安装vscode</p>
<h1 id="vscode介绍">vscode介绍 </h1>
<p>Visual Studio Code 是微软开发的一款开源编辑器，主要用于编写和调试代码。</p>
<h5 id="直接安装免费">直接安装（免费） </h5>
<pre data-role="codeBlock" data-info="bash" class="language-bash bash"><code><span class="token comment"># 下载地址</span>
https://code.visualstudio.com/
</code></pre><pre data-role="codeBlock" data-info="bash" class="language-bash bash"><code><span class="token comment"># 安装步骤</span>
<span class="token comment"># 1.下载安装包</span>
<span class="token comment"># 2.解压安装包</span>
<span class="token comment"># 3.运行code.exe</span>
</code></pre><p>vscode是一个开源软件，无需付费。</p>
<h5 id="vscode配置python环境">vscode配置python环境 </h5>
<h6 id="1-安装插件">1. 安装插件 </h6>
<p>打开vscode，点击插件栏的<code>插件</code> -&gt; <code>市场</code> -&gt; <code>搜索python</code> -&gt; <code>Python</code> -&gt; <code>安装</code></p>
<h6 id="2-配置环境">2. 配置环境 </h6>
<p>打开vscode，点击菜单栏的<code>文件</code> -&gt; <code>打开文件夹</code>，选择要打开的项目文件夹</p>
<h6 id="3-运行项目">3. 运行项目 </h6>
<p>找到启动文件，点击运行即可</p>
<h4 id="3-编辑器ide启动">3. 编辑器（IDE）启动 </h4>
<p>1.pycharm启动<br>
打开pycharm，点击菜单栏的<code>文件</code> -&gt; <code>打开</code>，选择要打开的项目文件夹</p>
<p>2.vscode启动<br>
打开vscode，点击菜单栏的<code>文件</code> -&gt; <code>打开文件夹</code>，选择要打开的项目文件夹</p>
<h3 id="数据库远程链接详解">数据库远程链接详解 </h3>
<p>要配置MySQL以允许远程连接，您需要进行以下步骤：</p>
<p>确保MySQL服务器已安装并正在运行。</p>
<p>打开MySQL服务器的配置文件。在Linux上，配置文件通常位于/etc/mysql/mysql.conf.d/mysqld.cnf或/etc/mysql/my.cnf。在Windows上，它可能位于C:\Program Files\MySQL\MySQL Server<version>\my.ini。</version></p>
<p>在配置文件中找到以下行，如果它们不存在，请添加它们：</p>
<pre data-role="codeBlock" data-info="sql" class="language-sql sql"><code>bind<span class="token operator">-</span>address <span class="token operator">=</span> <span class="token number">0.0</span><span class="token number">.0</span><span class="token number">.0</span>
</code></pre><p>这将使MySQL监听所有可用的网络接口。</p>
<h4 id="4-保存并关闭配置文件">4. 保存并关闭配置文件。 </h4>
<p>重新启动MySQL服务器以使更改生效。在Linux上，您可以使用以下命令：</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash bash"><code><span class="token function">sudo</span> <span class="token function">service</span> mysql restart
</code></pre><p>在Windows上，您可以通过“服务”管理器或使用相关命令行工具重新启动MySQL服务。</p>
<h4 id="6-现在您需要修改mysql用户的权限以允许远程连接连接到mysql服务器并执行以下命令">6. 现在，您需要修改MySQL用户的权限以允许远程连接。连接到MySQL服务器并执行以下命令： </h4>
<pre data-role="codeBlock" data-info="sql" class="language-sql sql"><code><span class="token keyword keyword-GRANT">GRANT</span> <span class="token keyword keyword-ALL">ALL</span> <span class="token keyword keyword-PRIVILEGES">PRIVILEGES</span> <span class="token keyword keyword-ON">ON</span> <span class="token operator">*</span><span class="token punctuation">.</span><span class="token operator">*</span> <span class="token keyword keyword-TO">TO</span> <span class="token string">'root'</span><span class="token variable">@'%'</span> IDENTIFIED <span class="token keyword keyword-BY">BY</span> <span class="token string">'your_password'</span> <span class="token keyword keyword-WITH">WITH</span> <span class="token keyword keyword-GRANT">GRANT</span> <span class="token keyword keyword-OPTION">OPTION</span><span class="token punctuation">;</span>
</code></pre><p>将your_password替换为您想要使用的密码。此命令授予root用户从任何远程主机连接到MySQL的权限。如果您希望限制连接的IP地址范围，请将'%'替换为相应的IP地址或IP地址范围。</p>
<h4 id="7-刷新权限使更改生效">7. 刷新权限使更改生效： </h4>
<pre data-role="codeBlock" data-info="sql" class="language-sql sql"><code>FLUSH <span class="token keyword keyword-PRIVILEGES">PRIVILEGES</span><span class="token punctuation">;</span>
</code></pre><p>现在，您应该能够从远程主机连接到MySQL服务器。使用以下命令测试连接：</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash bash"><code>mysql <span class="token parameter variable">-h</span> <span class="token operator">&lt;</span>remote_host_ip_address<span class="token operator">&gt;</span> <span class="token parameter variable">-u</span> root <span class="token parameter variable">-p</span>
</code></pre><p>将&lt;remote_host_ip_address&gt;替换为远程主机的IP地址。系统会提示您输入密码。成功登录后，表示远程连接已成功建立。</p>
<p>请注意，允许远程连接可能会带来安全风险。确保仅允许可信的主机访问您的MySQL服务器，并采取适当的安全措施，如使用强密码、定期更新和监控访问日志等。</p>

      </div>
      
      
    
    
    
    
    
    
  
    </body></html>